.TH deductionguidesforstd::queue 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
deductionguidesforstd::queue \- deductionguidesforstd::queue

.SH Synopsis
   Defined in header <queue>
   template< class Container >

   queue( Container )                                                 \fB(1)\fP \fI(since C++17)\fP

       -> queue<typename Container::value_type, Container>;
   template< class Container, class Alloc >

   queue( Container, Alloc )                                          \fB(2)\fP \fI(since C++17)\fP

       -> queue<typename Container::value_type, Container>;
   template< class InputIt >

   queue( InputIt, InputIt )                                          \fB(3)\fP (since C++23)

       -> queue<typename std::iterator_traits<InputIt>::value_type>;
   template< class InputIt, class Alloc >

   queue( InputIt, InputIt, Alloc )
       -> queue<typename std::iterator_traits<InputIt>::value_type,   \fB(4)\fP (since C++23)

          std::deque<typename
   std::iterator_traits<InputIt>::value_type, Alloc>>;
   template< ranges::input_range R >

   queue( std::from_range_t, R&& )                                    \fB(5)\fP (since C++23)

       -> queue<ranges::range_value_t<R>>;
   template< ranges::input_range R, class Allocator >

   queue( std::from_range_t, R&&, Allocator )                         \fB(6)\fP (since C++23)
       -> queue<ranges::range_value_t<R>,

          std::deque<ranges::range_value_t<R>, Allocator>>;

   These deduction guides are provided for queue to allow deduction from underlying
   container type.

   1) Deduces underlying container type from the argument.
   2) Same as \fB(1)\fP, except that the allocator is provided.
   3) Deduces the element type from the iterator, using std::deque<typename
   std::iterator_traits<InputIt>::value_type> as the underlying container type.
   4) Same as \fB(3)\fP, except that the allocator is provided.
   5) Deduces the element type from a std::from_range_t tag and an input_range.
   6) Same as \fB(5)\fP, except that the allocator is provided.

   These overloads participate in overload resolution only if

     * InputIt (if exists) satisfies LegacyInputIterator,
     * Container (if exists) does not satisfy Allocator,
     * for
       \fB(3)\fP
       (until C++23)
       \fB(4)\fP
       (since C++23), Alloc satisfies Allocator, and
     * std::uses_allocator_v<Container, Alloc> is true if both Container and Alloc
       exist.

   Note: the extent to which the library determines that a type does not satisfy
   LegacyInputIterator is unspecified, except that as a minimum integral types do not
   qualify as input iterators. Likewise, the extent to which it determines that a type
   does not satisfy Allocator is unspecified, except that as a minimum the member type
   Alloc::value_type must exist and the expression
   std::declval<Alloc&>().allocate(std::size_t{}) must be well-formed when treated as
   an unevaluated operand.

.SH Notes

               Feature-test macro               Value    Std           Feature
                                                               Iterator pair
                                                               constructors for
   __cpp_lib_adaptor_iterator_pair_constructor 202106L (C++23) std::queue and
                                                               std::stack; overloads
                                                               \fB(2)\fP and \fB(4)\fP
                                                               Ranges-aware
   __cpp_lib_containers_ranges                 202202L (C++23) construction and
                                                               insertion; overloads \fB(5)\fP
                                                               and \fB(6)\fP

.SH Example


// Run this code

 #include <queue>
 #include <vector>

 int main()
 {
     std::vector<int> v = {1, 2, 3, 4};
     std::queue s{v}; // guide #1 deduces std::queue<int, vector<int>>
 }
